

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>CephFS 目录条目名字规范化和大小写折叠 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="LazyIO" href="../lazyio/" />
    <link rel="prev" title="Ceph 文件系统 IO 路径" href="../cephfs-io-path/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">CephFS 目录条目名字规范化和大小写折叠</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/charmap.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id6">CephFS 内幕</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../mds-states/"> MDS 的各种状态</a></li>
<li class="toctree-l3"><a class="reference internal" href="../posix/"> POSIX 兼容性</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mds-journaling/"> MDS 日志记录</a></li>
<li class="toctree-l3"><a class="reference internal" href="../file-layouts/"> 文件布局</a></li>
<li class="toctree-l3"><a class="reference internal" href="../mdcache/"> 分布式元数据缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../dynamic-metadata-management/"> CephFS 内的动态元数据管理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-io-path/"> CephFS IO 路径</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 大小写敏感和规范化</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">规范化</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">大小写折叠</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">删除字符映射</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">限制不兼容的客户端访问</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">权限</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../lazyio/"> LazyIO</a></li>
<li class="toctree-l3"><a class="reference internal" href="../dirfrags/"> 目录分片的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../multimds/"> 多活 MDS 的配置</a></li>
<li class="toctree-l3"><a class="reference internal" href="../snapshots/"> 快照</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="cephfs">
<span id="charmap"></span><h1>CephFS 目录条目名字规范化和大小写折叠<a class="headerlink" href="#cephfs" title="Permalink to this heading"></a></h1>
<p>CephFS 允许把目录树配置成可以对目录条目名字施行<strong>规范化</strong>并有可能<strong>大小写折叠</strong>。对于像 Samba 这样的、通过网关导出的文件系统来说，
此功能一般是个有用的属性，因为这些网关会强制执行文件系统不区分大小写的视图，
所以，通常对接不区分大小写的文件系统会造成性能损失。</p>
<p>以下虚拟扩展属性可控制目录条目的<strong>字符映射</strong>（ character mapping ）规则：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.dir.casesensitive</span></code>: 用于设置目录大小写敏感性的布尔值。
如果为 true ，则对目录条目名称进行大小写折叠。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.dir.normalization</span></code>: 用于设置目录条目名称的 Unicode 规范化类型的字符串。
目前，客户端支持 D (<code class="docutils literal notranslate"><span class="pre">nfd</span></code>)、C (<code class="docutils literal notranslate"><span class="pre">nfc</span></code>)、KD (<code class="docutils literal notranslate"><span class="pre">nfkd</span></code>)和 KC (<code class="docutils literal notranslate"><span class="pre">nfkc</span></code>)等规范化格式。</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.dir.encoding</span></code>: 为目录条目名称使用和执行的编码设置字符串。
默认和目前唯一支持的编码是 UTF-8 (<code class="docutils literal notranslate"><span class="pre">utf8</span></code>)。</p></li>
</ul>
<p>还有一个方便的虚拟扩展属性，可用于获取大小写敏感性、
规范化和编码配置的 JSON 编码：</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">ceph.dir.charmap</span></code>: 目录的完整字符映射配置。</p></li>
</ul>
<p>它还可用于<strong>删除</strong>所有设置，并恢复目录条目名称的默认 CephFS 行为：
以 NUL 结尾、不含 <code class="docutils literal notranslate"><span class="pre">/</span></code> 的未解释字节。</p>
<p>操作这些扩展属性时，要注意以下限制：</p>
<ul class="simple">
<li><p>目录必须为空。</p></li>
<li><p>目录不得是快照的一部分。</p></li>
</ul>
<p>在已配置了 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 的目录下创建的新子目录将继承（复制）父目录的配置。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>您可以删除子目录继承的 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 配置，
前提条件是：该子目录为空，且不属于现有快照的一部分。</p>
</div>
<section id="id1">
<h2>规范化<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">ceph.dir.normalization</span></code> 属性支持下列规范化格式：</p>
<ul class="simple">
<li><p><strong>nfd</strong>: Form D (Canonical Decomposition ，标准分解)</p></li>
<li><p><strong>nfc</strong>: Form C (Canonical Decomposition, followed by Canonical Composition ，标准分解而后标准合成)</p></li>
<li><p><strong>nfkd</strong>: Form KD (Compatibility Decomposition， 兼容分解)</p></li>
<li><p><strong>nfkc</strong>: Form KC (Compatibility Decomposition, followed by Canonical Composition，兼容分解而后标准合成)</p></li>
</ul>
<p>字符映射配置的默认规范化格式是 <code class="docutils literal notranslate"><span class="pre">nfd</span></code> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>有关 Unicode 规范化格式的详情，参阅 <a class="reference external" href="https://unicode.org/reports/tr15/">Unicode 规范化标准文档</a>。</p>
</div>
<p>每当在路径遍历或查找过程中生成目录条目名称时，
在向 MDS 提交任何操作之前，
客户端会对名字进行规范化处理。在 MDS 端，
存储的只是这些已经规范化过的目录条目名字。</p>
<p>例如，在目录上设置规范化：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ setfattr -n ceph.dir.normalization -v &quot;&quot; foo/

$ getfattr -n ceph.dir.charmap foo/
# file: foo/
ceph.dir.charmap=&quot;{\&quot;casesensitive\&quot;:true,\&quot;normalization\&quot;:\&quot;nfd\&quot;,\&quot;encoding\&quot;:\&quot;utf8\&quot;}&quot;

$ getfattr -n ceph.dir.normalization foo/
# file: foo/
ceph.dir.normalization=&quot;nfd&quot;
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>设置空字符串时， MDS 将采用默认规范化。</p>
</div>
<p>所有字符映射配置都必须启用一种规范化。
删除规范化将恢复默认值：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ setfattr -n ceph.dir.normalization -v nfc foo/
$ getfattr -n ceph.dir.normalization foo/
# file: foo/
ceph.dir.normalization=&quot;nfc&quot;

$ setfattr -x ceph.dir.normalization foo/
$ getfattr -n ceph.dir.normalization foo/
# file: foo/
ceph.dir.normalization=&quot;nfd&quot;
</pre></div>
</div>
<p>要删除一个目录的规范化，
必须删除配置的 <code class="docutils literal notranslate"><span class="pre">ceph.dir.charmap</span></code> 。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>MDS 会给目录条目维护一个 <code class="docutils literal notranslate"><span class="pre">alternate_name</span></code> 元数据
（也用于加密），可以给客户端保留应用程序要用的、
原始的未规范化过的名字。 MDS 不会对此元数据做任何解释；
它仅仅用于让客户端重建目录条目的原始名字。</p>
</div>
</section>
<section id="id2">
<h2>大小写折叠<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p><code class="docutils literal notranslate"><span class="pre">ceph.dir.casesensitive</span></code> 属性应该设置布尔值。
默认情况下，名字区分大小写（是 POSIX 文件系统的正常情况）。
把此值设为 false 后，此目录（及其子目录）
将不区分大小写。</p>
<p>大小写折叠要求对名称也进行规范化处理。默认情况下，
在把目录设置为大小写不敏感后， <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 配置是这样的：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ setfattr -n ceph.dir.casesensitive -v 0 foo/
$ getfattr -n ceph.dir.casesensitive foo/
# file: foo/
ceph.dir.casesensitive=&quot;0&quot;

$ getfattr -n ceph.dir.charmap foo/
# file: foo/
ceph.dir.charmap=&quot;{\&quot;casesensitive\&quot;:false,\&quot;normalization\&quot;:\&quot;nfd\&quot;,\&quot;encoding\&quot;:\&quot;utf8\&quot;}&quot;
</pre></div>
</div>
<p>注意，设置目录的大小写敏感性时，
会顺带选定默认的规范化配置。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>规范化在大小写折叠之前应用。
MDS 所用的目录条目名字是经过大小写折叠和规范化的名字。</p>
</div>
</section>
<section id="id3">
<h2>删除字符映射<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>如果目录是空的，也不属于快照，
那么它的 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 就可以删掉：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ setfattr -x ceph.dir.charmap foo/
</pre></div>
</div>
<p>可以用下面的方法确认，此目录已经恢复成了默认的 CephFS 行为：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ getfattr -n ceph.dir.charmap foo/
foo/: ceph.dir.charmap: No such attribute
</pre></div>
</div>
<p>如果这个属性不存在，就说明这个目录没有配置字符映射。
注意，（以后）其子目录或父目录可能会有 charmap 配置，
但那个配置对本目录没有影响。
只有在创建目录时才会继承 charmap 配置。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>默认的 charmap 包含规范化配置，此行为不能禁用。
关闭此功能的唯一方法是删除这个
<code class="docutils literal notranslate"><span class="pre">charmap</span></code> 虚拟扩展属性。</p>
</div>
</section>
<section id="id4">
<h2>限制不兼容的客户端访问<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>MDS 用一个新的客户端特性位来保护带有 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 的目录树的访问权限。
MDS 不允许不支持 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 功能的客户端修改那些配置了 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 的目录。
unlink 文件或删除子目录操作除外。</p>
<p>您也可以要求所有客户端都必须理解 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 功能，
才能使用文件系统：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><style type="text/css">
span.prompt1:before {
  content: "# ";
}
</style><span class="prompt1">ceph<span class="w"> </span>fs<span class="w"> </span>required_client_features<span class="w"> </span>&lt;fs_name&gt;<span class="w"> </span>add<span class="w"> </span>charmap</span>
</pre></div></div><div class="admonition note">
<p class="admonition-title">Note</p>
<p>内核驱动程序并不支持 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 功能，
而且很可能也不会支持，因为现有的内核库对于大小写折叠和规范化格式不赞同。因此，
不建议把 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 加到必需的客户端功能中。</p>
</div>
</section>
<section id="id5">
<h2>权限<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<p>与其他 CephFS 虚拟扩展属性一样，客户端只能在具有 <strong>p</strong> 这个 MDS
auth cap 的目录上做 <code class="docutils literal notranslate"><span class="pre">charmap</span></code> 配置。查看配置不需要此 cap 。</p>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../cephfs-io-path/" class="btn btn-neutral float-left" title="Ceph 文件系统 IO 路径" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../lazyio/" class="btn btn-neutral float-right" title="LazyIO" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>